package com.easy.controller;

import com.easy.bean.FosterBookingBean;
import com.easy.service.FosterBookingService;
import com.easy.util.Page;
import com.easy.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("fosterBooking")
public class FosterBookingController {

    @Autowired
    FosterBookingService fosterBookingService;

    @PostMapping
    public Result add(@RequestBody FosterBookingBean fosterBookingBean){
        Object obj=fosterBookingService.add(fosterBookingBean);
        return Result.success(obj);
    }

    @DeleteMapping("{id}")
    public Result del(@PathVariable("id") Integer id){
        int obj=fosterBookingService.del(id);
        return Result.success(obj);
    }

    @PutMapping
    public Result edit(@RequestBody FosterBookingBean fosterBookingBean){
        Object obj=fosterBookingService.edit(fosterBookingBean);
        return Result.success(obj);
    }

    @GetMapping("all")
    public Result all(FosterBookingBean fosterBookingBean){
        Object obj=fosterBookingService.all(fosterBookingBean);
        return Result.success(obj);
    }

    @GetMapping("{id}")
    public Result one(@PathVariable("id") Integer id){
        Object obj=fosterBookingService.one(id);
        return Result.success(obj);
    }

    @GetMapping("page")
    public Result page(Page page, FosterBookingBean fosterBookingBean){
        //查询一共有多少数据
        //查询当前页要显示的数据
        //将以上数据封装到page对象中
        fosterBookingService.page(page,fosterBookingBean);
        //返回page对象
        return Result.success(page);
    }

}






















